﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using WorldSource.Components;

namespace WorldSource.Entities
{
    public class GameObject : DrawableGameComponent
    {
        public List<Component> components = new List<Component>();
        SpriteBatch spriteBatch;

        private Texture2D _texture;
        public Texture2D Texture
        {
            get { return _texture; }
            set { _texture = value; }
        }

        private Vector2 _position;
        public Vector2 Position
        {
            get { return _position; }
            set { _position = value; }
        }
        public GameObject(Game game, Texture2D texture)
            : base(game)
        {
            _texture = texture;
            spriteBatch = Game1.spriteBatch;
        }

        public override void Update(GameTime gameTime)
        {
            foreach (Components.Component comp in components)
            {
                comp.Update();
            }
            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            spriteBatch.Draw(_texture, _position, Color.White);
            base.Draw(gameTime);
        }
    }
}
